import schedule
import time
from datetime import datetime
from Terminal_division.warn_infomation.dingtalk_warn import MessagePush

def is_workday():
    # 周一至周五为工作日（0-4）
    return datetime.today().weekday() < 5

def job_9am():
    if is_workday():
        MessagePush().workday_push()

def job_6pm():
    if is_workday():
        MessagePush().workday_push()
    else:
        MessagePush().weekend_push()

# 设置每天的定时任务
schedule.every().day.at("09:00").do(job_9am)
schedule.every().day.at("18:00").do(job_6pm)

# 持续运行定时任务检查
while True:
    schedule.run_pending()
    time.sleep(5)